package com.xaicode.auth.security;

import cn.dev33.satoken.listener.SaTokenListenerForLog;
import cn.dev33.satoken.stp.SaLoginModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 用户行为监听器
 * 
 * @date 2024/12/6
 */
@Slf4j
@Component
public class UserActionListener extends SaTokenListenerForLog {

    @Override
    public void doLogin(String loginType, Object loginId, String tokenValue, SaLoginModel loginModel) {
        log.info("账号 [{}] 登录成功 (loginType={},loginModel={}), 会话凭证Token={}", loginId, loginType, loginModel, tokenValue);
    }

    @Override
    public void doLogout(String loginType, Object loginId, String tokenValue) {
        log.info("账号 [{}] 注销登录 (loginType={}), 会话凭证Token={}", loginId, loginType, tokenValue);
    }

}
